package com.wtzz.police.base.controller;
/**
 * 附件Controller
 */
import com.wtzz.police.base.entity.Attachment;
import com.wtzz.police.base.model.enums.WtzzResponse;
import com.wtzz.police.base.model.response.ResponseBean;
import com.wtzz.police.base.service.AttachmentService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Optional;

//@Api(tags = "附件", hidden = true)
@ApiIgnore
@Controller
@RequestMapping("attachment")
// FIXME: 19/11/22 附件的处理还没实现
public class AttachmentController {

    @Autowired
    private AttachmentService service;

    @ApiOperation(value = "上传")
    @PostMapping("upload")
    @ResponseBody
    public ResponseBean<Attachment> upload(MultipartFile file) {
        // FIXME: 19/11/22
        Attachment e = new Attachment();
        return ResponseBean.of(e);
    }

    @ApiOperation("删除")
    @ApiImplicitParam(value = "附件id", required = true)
    @DeleteMapping("{id}")
    @ResponseBody
    public ResponseBean<Attachment> delete(
            @PathVariable
                    String id) {
        // FIXME: 19/11/22
        service.delete(id);
        return new ResponseBean<>(true, WtzzResponse.SUCCESS_OPTION);
    }

    @ApiOperation("下载文件")
    @ApiImplicitParam(value = "附件id", required = true)
    @GetMapping("download/{id}")
    public void download(
            @PathVariable
                    String id, HttpServletResponse response) throws IOException {
        // FIXME: 19/11/22
    }

}
